/*** Eclipse Class Decompiler plugin, copyright (c) 2012 Chao Chen (cnfree2000@hotmail.com) ***/
package com.qihoopp.qcoinpay;

import android.app.Activity;
import android.content.Context;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.Bitmap.Config;
import android.graphics.Canvas;
import android.graphics.drawable.Drawable;
import android.util.DisplayMetrics;
import android.view.View;
import android.view.inputmethod.InputMethodManager;
import com.qihoopp.framework.LogUtil;
import com.qihoopp.framework.MD5;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map.Entry;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public final class cz {
    private static int a = 1;
    private static String[] b = { "reset_question", "reset_answer", "reset_smscode", "reset_paypass",
            "reset_paypass_md5" };
    private static String[] c = new String[0];

    public static int a() {
        return (a++);
    }

    public static int a(Context paramContext, float paramFloat) {
        paramContext = paramContext.getResources().getDisplayMetrics().density;
        return (int) (paramFloat * paramContext + 0.5F);
    }

    public static Bitmap a(Drawable paramDrawable) {
        Bitmap localBitmap = Bitmap.createBitmap(paramDrawable.getIntrinsicWidth(), paramDrawable.getIntrinsicHeight(),
                (paramDrawable.getOpacity() != -1) ? Bitmap.Config.ARGB_8888 : Bitmap.Config.RGB_565);
        Canvas localCanvas = new Canvas(localBitmap);
        paramDrawable.setBounds(0, 0, paramDrawable.getIntrinsicWidth(), paramDrawable.getIntrinsicHeight());
        paramDrawable.draw(localCanvas);
        return localBitmap;
    }

    public static void a(Activity paramActivity) {
        try {
            InputMethodManager localInputMethodManager = (InputMethodManager) paramActivity
                    .getSystemService("input_method");
            if (((paramActivity = paramActivity.getCurrentFocus()) != null) && (localInputMethodManager != null)
                    && ((paramActivity = paramActivity.getWindowToken()) != null))
                localInputMethodManager.hideSoftInputFromWindow(paramActivity, 2);
            return;
        } catch (Exception localException) {
            LogUtil.e("PPUtils", "Exception", localException);
        }
    }

    public static String a(HashMap paramHashMap, String paramString) {
        Collections.sort(paramHashMap = new ArrayList(paramHashMap.entrySet()), new ax());
        StringBuilder localStringBuilder = new StringBuilder();
        paramHashMap = paramHashMap.iterator();
        while (paramHashMap.hasNext()) {
            Map.Entry localEntry = (Map.Entry) paramHashMap.next();
            localStringBuilder.append((String) localEntry.getKey()).append("=").append((String) localEntry.getValue())
                    .append("&");
        }
        if (localStringBuilder.toString().endsWith("&"))
            localStringBuilder.deleteCharAt(localStringBuilder.length() - 1);
        localStringBuilder.append(paramString);
        paramHashMap = MD5.getMD5(localStringBuilder.toString());
        LogUtil.d("PPUtils", "MD5Sign=" + paramHashMap);
        return paramHashMap;
    }

    public static String a(String paramString, int paramInt) {
        if ((paramString == null) || (paramInt <= 0) || (paramString.length() < paramInt))
            return null;
        LogUtil.d("PPUtils", "getFixedNumber, str is : " + paramString);
        paramInt = Pattern.compile("\\d{" + paramInt + "}").matcher(paramString);
        Object localObject = null;
        String str;
        if (paramInt.find()) {
            int i;
            paramInt = (i = paramInt.start()) + paramInt.group().length();
            str = paramString.substring(i, paramInt);
        }
        return str;
    }

    public static String b(HashMap paramHashMap, String paramString) {
        try {
            StringBuilder localStringBuilder = new StringBuilder();
            for (int i = 0; i < b.length; ++i) {
                if (!(paramHashMap.containsKey(b[i])))
                    continue;
                localStringBuilder.append(b[i] + "=" + ((String) paramHashMap.get(b[i])) + "&");
                paramHashMap.remove(b[i]);
            }
            for (i = 0; i < c.length; ++i) {
                if (!(paramHashMap.containsKey(c[i])))
                    continue;
                localStringBuilder.append(c[i] + "=" + ((String) paramHashMap.get(c[i])) + "&");
                paramHashMap.remove(c[i]);
            }
            if (localStringBuilder.length() > 0)
                localStringBuilder.deleteCharAt(localStringBuilder.length() - 1);
            cv localcv = new cv(paramString.substring(0, 16), paramString.substring(16, paramString.length()),
                    "AES/CBC/PKCS5Padding");
            LogUtil.d("PPUtils", "secureParams = " + localStringBuilder.toString());
            return cw.a(localcv.a(localStringBuilder.toString()));
        } catch (Exception localException) {
            if (!(paramHashMap.containsKey("isapk")))
                paramHashMap.put("isapk", "Y");
            throw localException;
        }
    }

    public static boolean a(CharSequence paramCharSequence) {
        int i = paramCharSequence.length();
        for (int j = 0; j < i; ++j)
            if (!(Character.isDigit(paramCharSequence.charAt(j))))
                return false;
        return true;
    }

    public static boolean b(CharSequence paramCharSequence) {
        int i = paramCharSequence.length();
        for (int j = 0; j < i; ++j)
            if (!(Character.isLetter(paramCharSequence.charAt(j))))
                return false;
        return true;
    }

    public static boolean c(CharSequence paramCharSequence) {
        int i = paramCharSequence.length();
        for (int j = 0; j < i; ++j)
            if ((Character.isDigit(paramCharSequence.charAt(j))) || (Character.isLetter(paramCharSequence.charAt(j))))
                return false;
        return true;
    }
}